/**
 * <copyright>
 * </copyright>
 *
 */
package lco.cRLanguage.impl;

import lco.cRLanguage.CRLanguagePackage;
import lco.cRLanguage.Callable;
import lco.cRLanguage.IndexedVariable;
import lco.cRLanguage.NumericFunctionExpression;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Numeric Function Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lco.cRLanguage.impl.NumericFunctionExpressionImpl#getInt <em>Int</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.NumericFunctionExpressionImpl#getDouble <em>Double</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.NumericFunctionExpressionImpl#getIndexedVariable <em>Indexed Variable</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.NumericFunctionExpressionImpl#getCallable <em>Callable</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class NumericFunctionExpressionImpl extends MinimalEObjectImpl.Container implements NumericFunctionExpression
{
  /**
   * The default value of the '{@link #getInt() <em>Int</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInt()
   * @generated
   * @ordered
   */
  protected static final int INT_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getInt() <em>Int</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInt()
   * @generated
   * @ordered
   */
  protected int int_ = INT_EDEFAULT;

  /**
   * The default value of the '{@link #getDouble() <em>Double</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDouble()
   * @generated
   * @ordered
   */
  protected static final String DOUBLE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDouble() <em>Double</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDouble()
   * @generated
   * @ordered
   */
  protected String double_ = DOUBLE_EDEFAULT;

  /**
   * The cached value of the '{@link #getIndexedVariable() <em>Indexed Variable</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIndexedVariable()
   * @generated
   * @ordered
   */
  protected IndexedVariable indexedVariable;

  /**
   * The cached value of the '{@link #getCallable() <em>Callable</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCallable()
   * @generated
   * @ordered
   */
  protected Callable callable;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected NumericFunctionExpressionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRLanguagePackage.Literals.NUMERIC_FUNCTION_EXPRESSION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getInt()
  {
    return int_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInt(int newInt)
  {
    int oldInt = int_;
    int_ = newInt;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INT, oldInt, int_));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDouble()
  {
    return double_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDouble(String newDouble)
  {
    String oldDouble = double_;
    double_ = newDouble;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__DOUBLE, oldDouble, double_));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public IndexedVariable getIndexedVariable()
  {
    return indexedVariable;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetIndexedVariable(IndexedVariable newIndexedVariable, NotificationChain msgs)
  {
    IndexedVariable oldIndexedVariable = indexedVariable;
    indexedVariable = newIndexedVariable;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE, oldIndexedVariable, newIndexedVariable);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setIndexedVariable(IndexedVariable newIndexedVariable)
  {
    if (newIndexedVariable != indexedVariable)
    {
      NotificationChain msgs = null;
      if (indexedVariable != null)
        msgs = ((InternalEObject)indexedVariable).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE, null, msgs);
      if (newIndexedVariable != null)
        msgs = ((InternalEObject)newIndexedVariable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE, null, msgs);
      msgs = basicSetIndexedVariable(newIndexedVariable, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE, newIndexedVariable, newIndexedVariable));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Callable getCallable()
  {
    return callable;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCallable(Callable newCallable, NotificationChain msgs)
  {
    Callable oldCallable = callable;
    callable = newCallable;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE, oldCallable, newCallable);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCallable(Callable newCallable)
  {
    if (newCallable != callable)
    {
      NotificationChain msgs = null;
      if (callable != null)
        msgs = ((InternalEObject)callable).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE, null, msgs);
      if (newCallable != null)
        msgs = ((InternalEObject)newCallable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE, null, msgs);
      msgs = basicSetCallable(newCallable, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE, newCallable, newCallable));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE:
        return basicSetIndexedVariable(null, msgs);
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE:
        return basicSetCallable(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INT:
        return getInt();
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__DOUBLE:
        return getDouble();
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE:
        return getIndexedVariable();
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE:
        return getCallable();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INT:
        setInt((Integer)newValue);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__DOUBLE:
        setDouble((String)newValue);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE:
        setIndexedVariable((IndexedVariable)newValue);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE:
        setCallable((Callable)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INT:
        setInt(INT_EDEFAULT);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__DOUBLE:
        setDouble(DOUBLE_EDEFAULT);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE:
        setIndexedVariable((IndexedVariable)null);
        return;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE:
        setCallable((Callable)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INT:
        return int_ != INT_EDEFAULT;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__DOUBLE:
        return DOUBLE_EDEFAULT == null ? double_ != null : !DOUBLE_EDEFAULT.equals(double_);
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__INDEXED_VARIABLE:
        return indexedVariable != null;
      case CRLanguagePackage.NUMERIC_FUNCTION_EXPRESSION__CALLABLE:
        return callable != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (int: ");
    result.append(int_);
    result.append(", double: ");
    result.append(double_);
    result.append(')');
    return result.toString();
  }

} //NumericFunctionExpressionImpl
